{include file="public/layout" /}
<!--<script src="/static/plugs/layui-v2.5.6/layui.all.js"></script>-->
<style>
	html,body{
		background-color: #f2f2f2;
	}
</style>
<link rel="stylesheet" type="text/css" href="/static/design_page/designer.css" media="all">
<body>
<div class="layui-fluid" style="padding:8px">
	<div class="layui-row layui-col-space15">
		<div class="layui-card layui-col-md12">
			<div class="layui-form">
				<div class="layui-card-header">
					{if !empty($info) && $info['id']}<i class="fa fa-edit"></i> 页面编辑{else}<i class="fa fa-plus"></i> 添加页面{/if}
					<button class="layui-btn layui-btn-danger layui-btn-sm" onclick="pagesave(1)" style="float: right;margin-left:10px;margin-top: 6px;">设计完成</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm" onclick="closeSelf()" style="float: right;margin-left:10px;margin-top: 6px;"><i class="fa fa-close"></i> 关闭</button>
					<button class="layui-btn layui-btn-primary layui-btn-sm" onclick="pagesave(0)" style="float: right;margin-top: 6px;"><i class="fa fa-save"></i> 保存</button>
				</div>
				<div class="layui-card-body">
					<input type="hidden" id="pageid" value="{$info['id']}">
					<!-- 详情编辑器 -->
					{include file="design_page/designer" /}
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	var type = '{$type}';
	if(!type){
		type = 0;
	}
	console.log('type='+type);
	function closeSelf(){
		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index); //再执行关闭
	}
	function pagesave(savetype){
		var id = $('#pageid').val()
		var contentdata = geteditordata();
		var index = layer.load();
		$.post('{:url("save")}',{ op:'save',id:id,content:contentdata.datainfo,pageinfo:contentdata.pageinfo,type:type},function(data){
			layer.close(index);
			console.log(data);
			if(data.status == 1 && savetype ==1){
				layer.msg(data.msg);
				setTimeout(function(){
					parent.layer.closeAll();
					parent.location.reload()
					//parent.tableIns.reload()
				},1000)
			}else{
				if(data.pageid){
					$('#pageid').val(data.pageid)
				}
				layer.msg(data.msg);
			}
		})
	}
</script>
